const router = require('koa-router')();
const _token = require('../util/token');


router.post('/', async (ctx, next) =>{

    const loginData = ctx.request.body;
    let resData = { msg: 'please input loginCode' , code: 400, token: null}

    if(loginData && loginData.loginCode){

        const token = _token.createToken({userId: '1234coco'})
        _token.setCookies(ctx, token)
        
        resData = {
            msg: 'success',
            code: 200,
            token: token,
            sourceData: loginData
        }
    }
    
    ctx.body = resData
    
})




module.exports = router